<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <form class="layui-form layui-form-pane" action="">
            <div class="layui-form-item">
                <label class="layui-form-label required">管路名称</label>
                <div class="layui-input-block">
                    <input hidden name="id">
                    <input type="text" name="name" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <div class="layui-form-item">
                        <label class="layui-form-label">基准点位</label>
                        <div class="layui-input-block">
                            <input type="text" name="referencePoint" autocomplete="off"
                                   class="layui-input" placeholder="默认为管路、支路首支传感器">
                        </div>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <div class="layui-form-item">
                        <label class="layui-form-label required">泄漏标准</label>
                        <div class="layui-input-block">
                            <input type="text" name="standard" lay-verify="required|number" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <div class="layui-form-item">
                        <label class="layui-form-label required">持续时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="duration" lay-verify="required|number" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn" lay-submit="" lay-filter="saveBtn">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </form>
    </div>
</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return decodeURI(r[2]);
        return null; //返回参数值
    }

    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;
        var param = getUrlParam("id");
        if (param != null) {
            console.log(param);
        }

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.post('/pipeline/update', data.field, function (res) {
                if (res.code === 0) {
                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);
                    parent.layui.table.reload('currentTableId', {
                        page: {
                            curr: 1
                        }
                    })
                }
            });

            return false;
        });

    });
</script>
</body>
</html>
